from fastapi import APIRouter
from blog.models import Notification, Notification_Py
from typing import List
from fastapi_pagination import Page, paginate

router = APIRouter(prefix="/notifications", tags=["notification"])

@router.get("/", response_model=Page[Notification_Py])
async def get_notifications():
    return paginate(await Notification_Py.from_queryset(Notification.all()))

@router.post("/read/")
async def read_notifications(ids: List[int]):
    return await Notification.filter(id__in=ids).update(is_read=True)
